#ifndef __AKY_define_H__
#define __AKY_define_H__

#include <time.h>
#include <stdlib.h>
#include "aky_program/aky_config.h"

typedef struct 
{
    uint8_t  year:7;//
    uint8_t  month:4;//
    uint8_t  day:5;//
    uint8_t  hour:5;//
    uint8_t  min:6;//
    uint8_t  secon:6;//
}s_time_t;
typedef enum 
{
    USER_1 = 0, // 用户
    USER_2,     // 用户
    USER_3,     // 用户

    USER_MAX,
}e_user_t;


typedef enum
{
    area_left = 0,
    area_right,
    area_non,
}e_slide_area_t;

typedef enum
{
    dir_up = 0,
    dir_down,
    dir_non,
}e_slide_dir_t;

typedef enum
{
    strength_non = 0,
    strength_1 = 1,
    strength_2,
    strength_3,
    strength_4,
    strength_5,
}e_slide_strength_t;

typedef struct
{
    e_slide_dir_t  dir;
    e_slide_strength_t  strength;//strength
    e_slide_area_t  area;
}s_slide_info_t;

typedef enum 
{
    MAN = 0,
    WOMAN,
}e_gender_t;


typedef enum
{
    STAT_CAL_ZERO = 0,
    STAT_TESTING_BP,
    STAT_SHOW_BP_RESULT,
    STAT_PRE_ADAPT,
    STAT_RETEST_BP,
    STAT_SHOW_ERR,
    STAT_MANUAL_STOP,
    STAT_HIGHT_BP,

    STAT_UNDEF,
}e_auto_test_stat_t;

typedef struct 
{
    uint8_t sys;
    uint8_t dia;
    uint8_t pul;
}s_bp_t;//血压数据

typedef struct 
{
    uint8_t  min:6;//
    uint8_t  secon:6;//
}s_train_time_t;//训练时长


typedef struct
{
    uint8_t voice_level;
    uint8_t bl_level;
    uint8_t flag_net_work : 1;

    uint8_t fill_byte1; // 填充几个字节用于校验 因为字节过小时校验不准确
    uint8_t fill_byte2;
    uint8_t fill_byte3;

    uint8_t check_sum;
} s_set_t;

typedef struct
{
    s_time_t s_time;//测试时间日期 时间
    s_train_time_t s_train_time;
    s_bp_t s_left_bp_start;//
    s_bp_t s_right_bp_start;//

    s_bp_t s_left_bp;//
    s_bp_t s_right_bp;//
    uint8_t TrainMode;
    uint16_t TrainPressure;
    uint8_t flag_syn:1;
    uint8_t flag_ful_dat:1;

    uint8_t check_sum;
} s_mem_t;

#define AKY_10MS_CNT (1)
#define AKY_100MS_CNT (AKY_10MS_CNT * 10)
#define AKY_1S_CNT (10 * AKY_100MS_CNT)

#define BL_LEVEL_MAX (5)
#define BL_LEVEL_STEP_VAL (20)

#define VOICE_LEVEL_MAX (5)
#define VOICE_MIN_VAL_VIDEO (35)
#define VOICE_LEVEL_STEP_VAL_VIDEO ((100 - VOICE_MIN_VAL_VIDEO) / VOICE_LEVEL_MAX)
#define VOICE_LEVEL_STEP_VAL 20

#if 00
#define AUTO_RUN_TIME (AUTO_STEP_TIME + 10)//S
#define AUTO_STEP_TIME (30)//S

#else
//自动训练模式
#define AUTO_TIME_MAX (60 * 50)//最大时间
#define AUTO_STEP_TIME (60 * 5)//步骤时间
#define AUTO_RUN_TIME (AUTO_TIME_MAX - AUTO_STEP_TIME)//循环时间 = 

#endif

#define AKY_ASM_NOP() __NOP()

extern uint8_t pre_adapt_mode_sel;
extern uint8_t flag_manual_pre_adapt;
extern uint8_t g_flag_jump_to_fast_test;
extern volatile uint8_t g_flag_emc_mode;

#define DEFUALT_HOUR 8
#define DEFUALT_MIN 10

#define MAX_PUL (170ul)     // 心率上限
#define MIN_PUL (40ul)      // 心率下限
#define MAX_SYS 255         //高压上限
#define MIN_SYS 50          //高压下限
#define MAX_DIA 200         //低压上限
#define MIN_DIA 30          //低压下限


#endif //


